Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resharding: cleanup #585

Merged
merged 5 commits into from
Jan 30, 2025
Merged

resharding: cleanup #585

merged 5 commits into from
Jan 30, 2025

Conversation

staffik
Copy link
Contributor

@staffik staffik commented Jan 30, 2025

No description provided.

@staffik staffik marked this pull request as ready for review January 30, 2025 11:55
@staffik staffik requested a review from a team as a code owner January 30, 2025 11:55
Copy link
Contributor

@wacban wacban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

neps/nep-0568.md Outdated
Comment on lines 117 to 118
Since [Stateless Validation][NEP-508], all shards tracking is no longer required. Currently, shard cleanup has not been implemented. We propose a cleanup mechanism that will also handle post-resharding cleanup.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you define briefly what is state cleanup and under what circumstances it is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 333544c

neps/nep-0568.md Outdated

Since [Stateless Validation][NEP-508], all shards tracking is no longer required. Currently, shard cleanup has not been implemented. We propose a cleanup mechanism that will also handle post-resharding cleanup.

When garbage collection removes the last block of an epoch from the canonical chain, we determine which shards were tracked during that epoch by examining the shards present in `TrieChanges` at that block. Similarly, we collect information on shards tracked in subsequent epochs, up to the present one. A shard State is removed only if:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: two spaces between "collect" and "information"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 333544c

neps/nep-0568.md Outdated

#### Negative refcounts

Some trie keys (e.g. `TrieKey::DelayedReceipt`) are shared among child shards, but their corresponding State is not duplicated. The `DBCol::State` column uses reference counting, meaning some data is counted only once, despite being referenced by multiple child shards. This can result in negative refcounts when the data is later removed. To mitigate this, we modify the RocksDB `refcount_merge` behavior so that negative refcounts are clamped to 0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you mention that this is sub-optimal, why, and that we should follow up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 333544c

@staffik staffik requested a review from wacban January 30, 2025 13:10
Copy link

@Trisfald Trisfald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

neps/nep-0568.md Outdated
@@ -112,6 +112,22 @@ Cold storage uses the same mapping strategy to manage shard state during reshard

This approach minimizes complexity while maintaining consistency across hot and cold storage.

#### State cleanup

Since [Stateless Validation][NEP-508], all shards tracking is no longer required. Currently, shard cleanup (e.g. when we stopped tracking one shard and started tracking another shard) has not been implemented. With resharding, we would also want to cleanup parent shard once we stop tracking all its descendants. We propose a shard cleanup mechanism that will also handle post-resharding cleanup.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't stateless validation NEP-509?

@staffik staffik merged commit 58bb90d into resharding Jan 30, 2025
1 check passed
@staffik staffik deleted the stafik/resharding/cleanup branch January 30, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: NEW
Development

Successfully merging this pull request may close these issues.

3 participants